#ifndef SCRIBBLEAREA_H
#define SCRIBBLEAREA_H

#include <QWidget>


class ScribbleArea : public QWidget
{
    Q_OBJECT
public:
    explicit ScribbleArea(QWidget *parent = nullptr);

signals:

    void DebugText();
    void DebugText(QPoint pos);

public slots:

    void clearImage();
    void print();

protected:

    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;

    void paintEvent(QPaintEvent *event) override;

    void resizeEvent(QResizeEvent *event) override;

private:

    bool modified;
    // is drawing
    bool scribbling;

    int myPenWidth;
    QColor myPenColor;

    QImage image;

    QPoint lastPaint;

private:

    void drawLineTo(const QPoint &endPoint);
    void resizeImage(QImage *img, const QSize &newSize);

public:

    bool openImage(const QString &fileName);
    bool saveImage(const QString &fileName, const char* FileFormat);
    void setPenColor(const QColor &newColor);
    void setPenWidth(int newWidth);

    bool isModified() const;
    QColor penColor() const {return myPenColor;}
    int penWidth() const {return myPenWidth;}

};

#endif // SCRIBBLEAREA_H
